home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / jam / jamdisk1 / npr2 / npr2.doc / npr2.doc
Text File  |  1995-03-18  |  7KB  |  219 lines

  1. *              NPR2 v1.0. 28th September 1990
  2. *              ------------------------------
  3.  
  4. * The Problem
  5. * -----------
  6.  
  7. *    PAL Amigas occasionally boot up with an NTSC 200-line screen.
  8. *    This is rather annoying, as windows won't open to full size,
  9. *    and some programs won't run. The machine has to be reset - and
  10. *    there's always the possibility of the problem recurring on
  11. *    reboot.
  12.  
  13. * The Solution
  14. * ------------
  15.  
  16. *    Declan Mc Ardle wrote a neat little program called NoPalReset
  17. *    which checked the DisplayFlags in GfxBase. If the screen was
  18. *    NTSC, the machine was reset using the proper Commodore Reset
  19. *    Code.
  20.  
  21. * The Other Problem
  22. * -----------------
  23.  
  24. *    NoPalReset worked fine on most Amigas (including mine) but
  25. *    users of newer machines (mostly B2000s) reported repeated Guru
  26. *    Meditations. Some unfortunates even got their hard disks
  27. *    scrambled.¹
  28.  
  29. *                --------
  30. *  ¹: This is purely on hearsay, so I cannot prove it.
  31. *     No disrespect is implied in any way towards Mr. Mc Ardle.
  32. *                --------
  33.  
  34. *    This seemed odd, because the source code supplied with
  35. *    NoPalReset seemed correct. There was one tiny mistake, but
  36. *    that would probably not cause any problems (and it would only
  37. *    be executed if your machine was in a *bad* way anyway).
  38.  
  39. *    Disassembling the executable image provided a new lead; the
  40. *    source and the object code didn't match. There were a couple
  41. *    of subtle nuances which could lead to problems.
  42.  
  43. *    Commodore's Reset Code MUST be LONGWORD aligned. It was only
  44. *    word aligned in NoPalReset, and this could cause problems.
  45. *    Also a novel (shortcut ? I'm not sure) method was used in
  46. *    determining the display mode; this probably wouldn't cause any
  47. *    damage, but is contrary to Official Policy.
  48.  
  49. * The Solution
  50. * ------------
  51.  
  52. *    Enter NPR2 (NoPALReset 2). It does everything that NoPalReset
  53. *    was supposed to do, but strictly by the book. It's been fairly
  54. *    heavily tested; assuming the Relocator keeps its promise to
  55. *    relocate to longword boundaries (as it must) the Commodore
  56. *    Reset Code will be longword aligned. All libraries opened are
  57. *    closed on exit, so no memory will be lost
  58.  
  59. * Using NPR2
  60. * ----------
  61.  
  62. *    Copy the NPR2 program into the C: directory of your boot disk
  63. *    - it's only 188 bytes long. Now edit your S:Startup-Sequence,
  64. *    and insert a line at the start reading
  65.  
  66. *                C:NPR2
  67.  
  68. *    Resave your S:Startup-Sequence, and the next time you reboot
  69. *    NPR2 will make sure you get a PAL screen.
  70.  
  71. *    RUNNING NPR2 ON AN NTSC AMIGA IS SINGULARLY POINTLESS and is
  72. *    therefore not recommended.
  73.  
  74. *    When NPR2 reboots the machine, you get the bright white screen
  75. *    very suddenly. This can be a disconcerting if you're not
  76. *    expecting it. Therefore it's not clever to install NPR2 on
  77. *    someone else's machine without telling them, since nervous
  78. *    users don't appreciate being traumatised.
  79.  
  80. * About the Source
  81. * ----------------
  82.  
  83. *    Declan's code was very well commented, so only needed
  84. *    rearranging and patching to fix it up. It used a lot of
  85. *    includes for such a small program, so the relevant details
  86. *    were spliced in to make the source file self-contained. It's
  87. *    also strictly Metacomco ASSEM compatible now, only because I
  88. *    don't have DevPac 2.
  89. *    [Fixing the source wasn't helped by a misprint in a reference
  90. *     book which said that gb_DisplayFlags is actually one longword
  91. *    on from where it really is. That got me for a while.]
  92.  
  93. *    To rebuild NPR2, just run this file (NPR2.DOC) through your
  94. *    favourite assembler. It's your assembler's fault (for not
  95. *    being ASSEM compatible) if any errors crop up.
  96.  
  97. *    For Charlie Gibbs' A68k,
  98.  
  99. *            A68K NPR2.DOC
  100.  
  101. *    and then link (using The Software Distillery's Blink)
  102.  
  103. *            Blink NPR2.o
  104.  
  105. *    Depending on your assembler's ability to optimise branches,
  106. *    you should get an executable of around 188 bytes.
  107.  
  108. * Tools used
  109. * ----------
  110.  
  111. *    All the software tools used to build NPR2 are freely
  112. *    distributable, and available in the Fred Fish Collection.
  113.  
  114. *     Tool    Name   Version      Author          Fish Disk
  115. *   -----------------------------------------------------------------
  116. *   Text Editor DME    1.40    Matt Dillon         359
  117. *   Assembler    A68K    2.61    Charlie Gibbs         314
  118. *   Linker    Blink    6.7    The Software Distillery  314
  119. *   Monitor    Mon    1.24    Timo Rossi         310
  120. *   Calculator    Calc    3.0    Jimmy Yang         210
  121.  
  122. * Distribution
  123. * ------------
  124.  
  125. *    This work (NPR2.DOC and the NPR2 executable) may be freely
  126. *    distributed by any means as long as
  127.  
  128. *      - no charge is made for the work itself
  129.  
  130. *      - NPR2.DOC and the NPR2 executable are not altered
  131.  
  132. *      - NPR2 is not documented in any other way apart from a
  133. *        verbatim NPR2.DOC
  134.  
  135. *    You are free to make changes to NPR2.DOC, but you must not
  136. *    distribute the modified forms under the same name. If any
  137. *    changes are made to this document, my name and address MUST be
  138. *    removed too.
  139.  
  140. *    No guarantee is given that this software fulfils any specific
  141. *    task or purpose. Statements made herein which constitute an
  142. *    infringement of local statutory rights are invalid.
  143.  
  144. *                    Stewart C. Russell
  145. *                     140 Capelrig Road
  146. *                      Newton Mearns
  147. *                       Glasgow
  148. *                        SCOTLAND
  149.  
  150. *    Length of file NPR2 is 188 bytes.
  151. *    Length of file NPR2.DOC is 06975 bytes.
  152.  
  153. *    And now, for some source code...
  154.  
  155.     IDNT NPR2
  156.  
  157. * NPR2 by Stewart C. Russell, 28th September 1990
  158. * Based on `NoPalReset' by Declan Mc Ardle.
  159. * Detects if Amiga is in NTSC or PAL mode, resets if in NTSC mode.
  160.  
  161.     SECTION NoPALReset,CODE
  162.  
  163. _AbsExecBase     EQU 4
  164. _LVOOpenLibrary  EQU -552
  165. _LVOCloseLibrary EQU -414
  166. _LVOSupervisor     EQU -30
  167. gb_DisplayFlags  EQU 206
  168. ERROR         EQU 20
  169. NTSC         EQU 1
  170.  
  171.     MOVE.L    _AbsExecBase,a6     Put ExecBase in a6.
  172.     LEA    GfxLib,a1        Put Gfx name in a1.
  173.     MOVE.L    #33,d0            Oldest Current Version.
  174.     JSR    _LVOOpenLibrary(a6)     Open Graphics Library.
  175.     MOVE.L    d0,_GfxBase        Put pointer in _GfxBase.
  176.     TST.L    d0            Was it 0 (Library Unobtainable) ?
  177.     BEQ    quit            If so exit, else -
  178.     MOVE.L    _GfxBase,a1        Put _GfxBase in a1.
  179.     MOVE.W    gb_DisplayFlags(a1),d0  Put Display Flags in d0.
  180.     CMP.W    #NTSC,d0        Compare it with NTSC (= 1).
  181.     BEQ    reboot            If it's equal, RESET.
  182.     JSR    CloseGfx        Close Graphics library.
  183.     CLR.L    d0            Clear d0. (No error code)
  184.     RTS                Go back to CLI.
  185.  
  186. quit:
  187.     MOVE.L     #ERROR,d0        Set d0 to FAIL error code.
  188.     RTS                Go back to CLI.
  189.  
  190. CloseGfx:
  191.     MOVE.L    _GfxBase,a1        Move address in _GfxBase to a1.
  192.     JSR    _LVOCloseLibrary(a6)    Close the Graphics Library.
  193.     RTS
  194.  
  195. * What follows is the official Commodore-Amiga Reset Code.
  196. * Accept *no* substitutes.
  197.  
  198. reboot:
  199.     MOVE.L    _AbsExecBase,a6     Get a pointer to ExecBase.
  200.     LEA.L    MagicResetCode(pc),a5   Location of code to Trap to.
  201.     JSR    _LVOSupervisor(a6)      Start Code (must use JSR).
  202.  
  203.     CNOP    0,4        IMPORTANT: Must be longword aligned.
  204. MagicResetCode:
  205.     LEA.L    2,a0        Point to JMP instruction at start of ROM.
  206.     RESET            All RAM goes away now!
  207.     JMP    (a0)            Rely on prefetch to execute this instruction.
  208.  
  209. * Only data and stuff follows. Technically it should go in a hunk of its own,
  210. * but that makes the program unnecessarily large.
  211.  
  212. GfxLib:
  213.     DC.B    'graphics.library',0
  214.     CNOP    0,4
  215. _GfxBase:
  216.     DC.L    0
  217.     END
  218.  
  219.